-- card: 6552 from stack: in.3 -- bmap block id: 0 -- flags: 4000 -- background id: 3241 -- name: LeafName ----- HyperTalk script ----- on Install get ChooseTargetStack() InstallResource XFCN,LeafName,it end Install -- part 1 (field) -- low flags: 81 -- high flags: 0007 -- rect: left=12 top=26 right=298 bottom=491 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 22 -- text size: 10 -- style flags: 0 -- line height: 13 -- part name: Source -- part 3 (button) -- low flags: 00 -- high flags: A003 -- rect: left=299 top=300 right=322 bottom=438 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Show Pascal Source ----- HyperTalk script ----- on mouseUp set the visible of card field 1 to not the visible of card field 1 if the visible of card field 1 is true then set the name of me to "Hide Pascal Source" else set the name of me to "Show Pascal Source" end mouseUp -- part contents for background part 16 ----- text ----- LEAFNAME XFCN version 1.5 Kevin Calhoun LeafName takes a full pathname and returns the last component of it. The last component is the string of characters following the last colon in the pathname. This is known as the "leaf name" of a file or directory. Examples: put LeafName("HD:My Best Years:1962:The Drive-In") --puts The Drive-In into the message box. put LeafName("Winkin:Blinkin:Nod") into theContainer --puts Nod into theContainer This XFCN used to be known as LastPathComponent, but that name is too long to type. -- part contents for card part 1 ----- text ----- UNIT LastPathComponent; { LeafName XFCN © 1988-1989 by the Trustees of Dartmouth College } { Written by Kevin Calhoun } { This source compatible with MPW Pascal 3.0 } (* Pascal LeafName.p Link -m ENTRYPOINT ∂ -o "YourFile" ∂ -rt XFCN=3530 ∂ -sn Main=LeafName ∂ LeafName.p.o ∂ "{PLibraries}"Paslib.o ∂ "{Libraries}"HyperXLib.o *) {$R-} INTERFACE USES Types, HyperXCmd; PROCEDURE EntryPoint (paramPtr : XCMDPtr); IMPLEMENTATION PROCEDURE GetLPC(paramPtr : XCMDPtr); FORWARD; PROCEDURE EntryPoint (paramPtr : XCMDPtr); BEGIN GetLPC(paramPtr); END; PROCEDURE GetLPC (paramPtr : XCMDPtr); VAR fullPathName : Str255; fileName : Str255; FUNCTION AfterLastColon (str : Str255) : Str255; VAR theLength, index : INTEGER; BEGIN theLength := LENGTH(str); index := theLength; IF POS(':', str) > 0 THEN BEGIN WHILE (str[index] <> ':') DO BEGIN index := index - 1; END; AfterLastColon := COPY(str, index + 1, theLength - index); END ELSE AfterLastColon := str; END; BEGIN IF paramPtr^.paramCount > 0 THEN BEGIN ZeroToPas(paramPtr, paramPtr^.params[1]^, fullPathName); fileName := AfterLastColon(fullPathName); paramPtr^.returnValue := PasToZero(paramPtr, fileName); END ELSE paramPtr^.returnValue := PasToZero(paramPtr, 'LeafName XFCN 1.5, 15 March 1989, ©1988-1989 Dartmouth College'); END; END.